﻿using System;
using System.Collections.Generic;
using Myotragus.Data.Domain;

namespace Myotragus.Data.Containers
{
	public interface IEntitiesContainer : IService
	{
		/// <summary>
		/// Resolves registered entity type.
		/// </summary>
		/// <seealso cref="Create{T}(object)"/>
		/// <typeparam name="TEntity">Entity interface</typeparam>
		/// <returns>A new entity instance</returns>
		TEntity Create<TEntity>()
			where TEntity : IEntity;

		/// <summary>
		/// Resolves registered entity type.
		/// </summary>
		/// <seealso cref="Create(Type,object)"/>
		/// <param name="tEntity">Entity interface</param>
		/// <returns>A new entity instance</returns>
		IEntity Create(Type tEntity);

		/// <summary>
		/// Resolves and initialize a registered entity type.
		/// </summary>
		/// <seealso cref="Create{T}()"/>
		/// <typeparam name="TEntity">Entity interface</typeparam>
		/// <param name="prototype">Initialization values in any object. Matching fields would be copied.</param>
		/// <returns>A new entity instance</returns>
		TEntity Create<TEntity>(object prototype)
			where TEntity : IEntity;

		/// <summary>
		/// Resolves and initialize a registered entity type.
		/// </summary>
		/// <seealso cref="Create(Type)"/>
		/// <param name="tEntity">Entity interface</param>
		/// <param name="prototype">Initialization values in any object. Matching fields would be copied.</param>
		/// <returns>A new entity instance</returns>
		IEntity Create(Type tEntity, object prototype);

		Type ResolveType(Type @interface);

		IEnumerable<Type> Interfaces { get; }
	}
}